package com.qdlc.p2p.dal.dto;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import com.qdlc.p2p.common.constant.Global;
import com.qdlc.p2p.common.util.DateUtil;

/**
 * VIP实体类
 *
 * @author liya
 * @version 1.1.0.0
 */
@Entity
@Table(name = Global.DB_PREFIX + "user_vip")
public class UserVip {

    /** 主键 */
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private long id;

    /** 用户ID */
    @Column(name = "user_id")
    private long userId;

    /** 拥有成长值 */
    private double growthValue;

    /** 所属vip等级 */
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "level_id")
    private UserVipLevel userVipLevel;

    /** 获得vip时间 */
    private Date vipTime;

    public UserVip() {
    }

    public UserVip(User user) {
        this.userId = user.getUserId();
        this.vipTime = DateUtil.getNow();
        this.userVipLevel = new UserVipLevel(1);
    }

    public long getId() {
        return id;
    }

    public void setId(long id) {
        this.id = id;
    }

    public double getGrowthValue() {
        return growthValue;
    }

    public void setGrowthValue(double growthValue) {
        this.growthValue = growthValue;
    }

    public long getUserId() {
		return userId;
	}

	public void setUserId(long userId) {
		this.userId = userId;
	}

	public UserVipLevel getUserVipLevel() {
        return userVipLevel;
    }

    public void setUserVipLevel(UserVipLevel userVipLevel) {
        this.userVipLevel = userVipLevel;
    }

    public Date getVipTime() {
        return vipTime;
    }

    public void setVipTime(Date vipTime) {
        this.vipTime = vipTime;
    }
}
